<?php

class Links_Backend_Links_List extends Backend_Component_List 
{
    
    /**
     * Path to the template file.
     *
     * @var string
     */
    protected $_template = 'links/backend/links/container.tpl';
    
    /**
     * @desc Define table in case of automatic build for SQL statement. 
     *
     * @param string
     */
    protected $_table = 'links';
    
    /**
     * @desc List columns. 
     *
     * @param array
     */
    protected $_columns = array('name', 'url');
    
    /**
     * @desc Form SQl statement. 
     *
     * @return  string
     */
    protected function _getQueryBody()
    {
        // set album title
        $this->_setAlbumTitle();
        
        $this->_where = '`category_id` = ' . $this->_activeFilter();
        
        return parent::_getQueryBody();
    }
    
    /**
    * Return active filter value
    * 
    * @return integer
    */
    protected function _activeFilter() 
    {
        return Links_Utils::activeFilter();
    }
    
    /**
    * Set album title
    * 
    * @param string $title
    */
    protected function _setAlbumTitle() 
    {
        Application::getResponse()->setTitle(
            get_array_element(Links_Utils::filtersList(), Links_Utils::activeFilter()));
    }
    
}